package com.controller;

import com.controller.vo.ResultVO;
import com.entity.LotteryPrize;
import com.github.pagehelper.PageInfo;
import com.service.LotteryPrizeService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName LotteryPrizeController
 * @Description TODO
 * @Author Kx
 * @Date 2025/6/18 9:35
 * @Version 1.0
 */
@RestController
@RequestMapping("/lotteryPrize")
public class LotteryPrizeController extends BaseController {
    private final LotteryPrizeService lotteryPrizeService;

    public LotteryPrizeController(LotteryPrizeService lotteryPrizeService) {
        this.lotteryPrizeService = lotteryPrizeService;
    }

    /**
     * @author: kx
     * @date: 2025/6/18 9:37
     * @param lotteryPrize : 奖品信息
     * @return com.controller.vo.ResultVO<java.lang.String>
     * @description: 添加抽奖奖品信息
    */
    @PostMapping("/addLotteryPrize")
    public ResultVO<String> addLotteryPrize(@RequestBody LotteryPrize lotteryPrize) {
        lotteryPrizeService.addLotteryPrize(lotteryPrize);
        return success("添加成功");
    }

    /**
     * @author: kx
     * @date: 2025/6/18 10:30
     * @param lotteryPrize : 奖品信息
     * @return com.controller.vo.ResultVO<java.lang.String>
     * @description: 修改奖品信息(主要修改库存和状态)
    */
    @PostMapping("/updateLotteryPrize")
    public ResultVO<String> updateLotteryPrize(@RequestBody LotteryPrize lotteryPrize) {
        lotteryPrizeService.updateLotteryPrize(lotteryPrize);
        return success("修改成功");
    }

    /**
     * @author: kx
     * @date: 2025/6/18 11:09
     * @return com.controller.vo.ResultVO<java.util.List<com.entity.LotteryPrize>>
     * @description: 查询所有上架奖品信息
    */
    @GetMapping("/getAllLotteryPrizes")
    public ResultVO<List<LotteryPrize>> getAllLotteryPrizes() {
        return success(lotteryPrizeService.getAllLotteryPrizes());
    }

    /**
     * @author: kx
     * @date: 2025/6/19 11:17
     * @param pageNum : 页码
     * @param pageSize : 每页数量
     * @return com.controller.vo.ResultVO<java.util.List<com.entity.LotteryPrize>>
     * @description: 分页查询所有奖品信息
    */
    @GetMapping("/getPagedLotteryPrizes")
    public ResultVO<List<LotteryPrize>> getPagedLotteryPrizes(@RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return success(lotteryPrizeService.getPagedLotteryPrizes(pageNum, pageSize));
    }

    /**
     * @author: kx
     * @date: 2025/6/19 11:38
     * @param keyword : 关键字
     * @param pageNum : 页码
     * @param pageSize : 每页数量
     * @return com.controller.vo.ResultVO<com.github.pagehelper.PageInfo<com.entity.LotteryPrize>>
     * @description: 根据关键字分页查询奖品信息
    */
    @GetMapping("/searchLotteryPrizesByKeyWord")
    public ResultVO<PageInfo<LotteryPrize>> searchLotteryPrizesByKeyWord(@RequestParam("keyword") String keyword, @RequestParam("pageNum") Integer pageNum, @RequestParam("pageSize") Integer pageSize) {
        return success(lotteryPrizeService.searchLotteryPrizesByKeyWord(keyword, pageNum, pageSize));
    }
}
